package com.ty.controller;

import com.ty.pojo.Fetters;
import com.ty.service.FettersService;
import com.ty.vo.PageResult;
import com.ty.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@RestController
@EnableSwagger2
@CrossOrigin
@RequestMapping("/fetters")
public class FettersController {
    @Autowired
    private FettersService fettersService;
    //查询羁绊表页面
    @GetMapping("/getFettersList")
    public SysResult getFettersList(@RequestBody PageResult pageResult, Fetters fetters){
        pageResult = fettersService.getFettersList(pageResult,fetters);
        return SysResult.success(pageResult);
    }
    //新增羁绊
    @PostMapping("/insertFetters")
    @Transactional
    public SysResult insertFetters(@RequestBody Fetters fetters){
        fettersService.insertFetters(fetters);
        return SysResult.success();
    }
    //修改羁绊表数据
    @PutMapping("/updateFetters")
    @Transactional
    public SysResult updateFetters(@RequestBody Fetters fetters){
        fettersService.updateFetters(fetters);
        return SysResult.success();
    }
    //删除羁绊表数据,伪删除
    @PutMapping("/updateState/{id}")
    public SysResult updateState(@PathVariable Integer id){
        fettersService.updateState(id);
        return SysResult.success();
    }
}
